home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 12 / BBS in a box XII-1.iso / Files / Bus / S / S7P 3.6 Manual.sit / S7P 3.6 Manual.rsrc / TEXT_141.txt < prev    next >
Encoding:
Text File  |  1993-11-14  |  4.3 KB  |  87 lines

  1. Interfacing with Claris Resolve¬Æ
  2.  
  3. In addition to the required AppleEvents and DoScript, Claris Resolve¬Æ Supports the following custom events:
  4.  
  5.     CLRS    GVAL    Extracts data from the current worksheet.
  6.   CLRS    PVAL    Puts data into the current worksheet.
  7.  
  8. Both of these events require a special record which must be created with the low-level functions. This record consists of top left and bottom right points, and a return type (for GVAL) or return value (for GVAL reply or PVAL) and is contained in another record.
  9.  
  10.   TABL    Record with the following fields:
  11.     TLPT    typeInteger  Top left cell in the range
  12.           BRPT    typeInteger  Bottom Right cell of the range
  13.           VAL     typeEnum     Return type (should be ‚ÄúTEXT‚Äù)
  14.  
  15. The code to create and send such a record would look something like this:
  16. _________________________________________________________________
  17. ` this is how to send a request to Claris¬Æ Resolve‚Ñ¢
  18. ` create the request range table
  19. $Err:=CreateAERec($tabl)
  20. $Err:=PutLongParam($tabl;"TLPT";"";100)
  21. $Err:=PutLongParam($tabl;"BRPT";"";200)
  22. $Err:=PutKeyword($tabl;"RTRN";"TEXT")
  23. ` create the record which holds the table
  24. $Err:=CreateAERec($reqList)
  25. $Err:=PutAERecord($reqlist;"TABL";$tabl)
  26. ` create the actual AppleEvent and add the record
  27. $Err:=CreateAppleEvent("CLRS";"GVAL";$Resolve;$GetValue)
  28. $Err:=PutAERecord($GetValue;"----";$reqList)
  29. $Err:=SendAppleEvent($GetValue;$Reply;kAEWaitReply;-1)
  30. ` extract the data from the reply record
  31. $Err:=GetAERecord($Reply;"----";$reqList)
  32. $Err:=GetAERecord($reqList;"TABL";$tabl)
  33. $Err:=GetTextParam($tabl;"VAL ";$resultString)
  34. ` clean up everything we allocated
  35. $Err:=DisposeDesc($tabl)
  36. $Err:=DisposeDesc($reqList)
  37. $Err:=DisposeDesc($Reply)
  38. $Err:=DisposeDesc($GetValue)
  39. _________________________________________________________________
  40.  
  41.  
  42. Interfacing with Microsoft Excel 4.0¬Æ
  43.  
  44. Excel¬Æ 4.0 supports most of the AppleEvent Registry (See Appendix D) and also allows any command or macro to be executed with the DoScript command.The most useful events are Set Data, Get Data, and Create Element. You can use these events to create new worksheets or charts, fill-in a range of cells, extract the contents of a range of cells, produce various kinds of charts, and copy a chart into 4D¬Æ as a picture field.
  45.  
  46. NOTE: Commands sent using DoScript will be executed asynchronously in Excel¬Æ while the 4D procedure continues to run. If 4D tries to send additional commands while Excel is still executing the last command, it can cause unexpected results. To make sure the 4D procedure and Excel are properly synchronized, use SendWithReply(Excel;‚Äùmisc‚Äù;‚Äùdosc‚Äù...) instead of DoScript.
  47.  
  48. To execute an Excel macro via DoScript, you must send it as a function call, for example DoScript($excel;‚Äù‚ÄôMacro1‚Äô!MyMacro()‚Äù). If you send only the macro name it will not be executed.
  49.  
  50. Example 1: Filling a range of cells from a 4D array 
  51. _________________________________________________________________
  52. $err:=CreateAEVT(“core”;”setd”;Excel;$aevt)
  53. if ($err=0)
  54.     $err:=PutObject($aevt;‚Äù----‚ÄùObjNamed(‚Äúcrng‚Äù;0;‚ÄùR1C1:R10C1‚Äù))
  55.     $err:=PutList($aevt;‚Äùdata‚Äù;ArrayOfValues)
  56.     $err:=SendAppleEvent($aevt;$reply;kAEWaitReply+CanInteract;-1)
  57.     $err:=DisposeDesc($reply)
  58.     $err:=DisposeDesc($aevt)
  59. end if
  60. _________________________________________________________________
  61.  
  62. Example 2: Creating a chart
  63. _________________________________________________________________
  64. $err:=DoScript(Excel;”Select(“+char(34)+”R1C1:R10C2”+char(34)+”)”)
  65. $err:=CreateAEVT(“core”;”crel”;Excel;$aevt)
  66. if ($err=0)
  67.     $err:=PutLongParam($aevt;‚Äùkocl‚Äù;‚Äùtype‚Äù;Long(‚Äúchrt‚Äù))     $err:=SendAppleEvent($aevt;$reply;kAEWaitReply+CanInteract;-1)
  68.     $err:=DisposeDesc($reply)
  69.     $err:=DisposeDesc($aevt)
  70. end if
  71. _________________________________________________________________
  72.  
  73. Example 3: Copying chart to 4D
  74. _________________________________________________________________
  75. $err:=CreateAEVT(“core”;”getd”;Excel;$aevt)
  76. if ($err=0)
  77.     $err:=PutObject($aevt;‚Äù----‚Äù;Obj(‚Äúchrt‚Äù;0;1))
  78.     $err:=PutLongParam($aevt;‚Äùrtyp‚Äù;‚Äùtype‚Äù;Long(‚ÄúSPIC‚Äù))
  79.     $err:=SendAppleEvent($aevt;$reply;kAEWaitReply+CanInteract;-1)
  80.     if ($err=0)
  81.         $err:=GetPicParam($reply;‚Äù----‚Äù;1;aPicture)
  82.     End if
  83.     $err:=DisposeDesc($reply)
  84.     $err:=DisposeDesc($aevt)
  85. End if
  86. _________________________________________________________________
  87.